# coding=utf-8
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings
from filebrowser.sites import site

admin.autodiscover()

urlpatterns = patterns('',
    url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), 
    url(r'^grappelli/', include('grappelli.urls')), #需在admin之前 
    url(r'^admin/filebrowser/', include(site.urls)), #需在admin之前
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', admin.site.urls), 
)

urlpatterns += patterns('enjoyorsite.views',
    url(r'^$', 'home', {'lang': 'en'}),
    url(r'^home/$', 'home', {'lang', 'en'}), 
    url(r'^index/$', 'home', {'lang', 'en'}),
    url(r'^([a-z]{2})/index/$', 'home'),
    # About
    url(r'^([a-z]{2})/about/$', 'about'),
    url(r'^([a-z]{2})/about/infrastructure/$', 'infrastructure'),
    url(r'^([a-z]{2})/about/mission/$', 'mission'), 
    url(r'^([a-z]{2})/about/overview/$', 'overview'), 
    # Contact
    url(r'^([a-z]{2})/contact/$', 'contact'), 
    # Education
    url(r'^([a-z]{2})/education/$', 'education'), 
    url(r'^([a-z]{2})/education/edu-prog/$', 'edu_prog'),
    url(r'^([a-z]{2})/education/adv-edu-prog/$', 'adv_edu_prog'),
    # FAQ
    url(r'^([a-z]{2})/faq/$', 'faq'), 
    # url(r'^enjoyorsite/', include('enjoyorsite.foo.urls')),
)

urlpatterns += patterns('apps.cooperation.views',
    url(r'^([a-z]{2})/cooperation/$', 'cooperation'),
)

urlpatterns += patterns('apps.joinus.views',
    url(r'^([a-z]{2})/join/$', 'join', {'job_area': None}),
    url(r'^([a-z]{2})/join/([a-z-0-9]+)/$', 'join'),
)

urlpatterns += patterns('apps.news.views',
    url(r'^([a-z]{2})/news/$', 'news', {'news_id': None}),
    url(r'^([a-z]{2})/news/(\d+)/$', 'news'),
)

urlpatterns += patterns('apps.person.views',
    url(r'^([a-z]{2})/community/$', 'community', {'department': 'technical-committee'}),
    url(r'^([a-z]{2})/community/([a-z-0-9]+)/$', 'community'),
)

urlpatterns += patterns('apps.research.views',
    url(r'^([a-z]{2})/research/$', 'research', {'department': None, 'article_id': None}),
    url(r'^([a-z]{2})/research/publications/$', 'publication'),
    url(r'^([a-z]{2})/research/([a-z-0-9]+)/$', 'research', {'article_id': None}),
    url(r'^([a-z]{2})/research/([a-z-0-9]+)/(\d+)$', 'research'),
)
